import Vue from 'vue'
import Router from 'vue-router'
import dashboard from '@/router/modules/dashboard'
import login from '@/router/modules/login'
import approval from '@/router/modules/approval'
import attendance from '@/router/modules/attendance'
import department from '@/router/modules/department'
import employee from '@/router/modules/employee'
import permission from '@/router/modules/permission'
import role from '@/router/modules/role'
import salary from '@/router/modules/salary'
import social from '@/router/modules/social'

Vue.use(Router)

export const constantRoutes = [
  login,
  dashboard,
  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  }
  // 404 page must be placed at the end !!!
  // { path: '*', redirect: '/404', hidden: true }
]

export const asyncRoutes = [
  department, // 组织架构
  role, // 角色管理
  employee, // 员工管理
  permission, // 权限管理
  attendance, // 考勤管理
  approval, // 审批管理
  salary, // 工资管理
  social // 社保管理
]
const createRouter = () => new Router({
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher
}

export default router
